package net.sf.jOpinionPoll.controller.questionario;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.log4j.Logger;

import net.sf.jOpinionPoll.controller.Controller;
import net.sf.jOpinionPoll.entity.Questionario;
import net.sf.jOpinionPoll.facade.QuestionarioFacade;

public class QuestionarioRelatorioController extends Controller {
	private static final long serialVersionUID = 5716162617154631849L;
	private static final Logger m_Logger = Logger.getLogger(QuestionarioRelatorioController.class);
    
	private QuestionarioFacade m_QuestionarioFacade;
    
    public QuestionarioRelatorioController() {
    }
    
    /* Facades */
    public QuestionarioFacade getQuestionarioFacade() {
        return m_QuestionarioFacade;
    }
    
    public void setQuestionarioFacade(QuestionarioFacade questionarioFacade) {
        m_QuestionarioFacade = questionarioFacade;
    }

    /* Listagem */
    public Map<String, Integer> getQuestionarioComboList() {
		m_Logger.info("Atualizando lista de entidades...");
		
		Map<String, Integer> map = new HashMap<String, Integer>();
    	List<Questionario> list = getQuestionarioFacade().list(0, -1);

		for (Questionario q : list) {
			map.put(q.getNome() + " [" + q.getId() + "]", q.getId());
		}

		return map;
    }
}